<?php
namespace app\Operation_management\controller;
use think\Controller;
use think\Db;
/**
 *权限管理
 */
class Range extends Logincheck
{
    function range()
    {
        $res = db('administrator')->where('grade', 2)->whereor('grade', 3)->order('grade')->select();
        // print_pre($res);
        foreach ($res as &$oneres) {
            if($oneres['time']){
                $oneres['time'] = date('Y-m-d H:i:s',$oneres['time']);
            }
        }
        $this->assign('users',$res);
        return $this->fetch();
    }


    function modify($id, $password, $grade,$nickname)
    {
        $update = ['password'=>$password, 'grade'=>$grade, 'nickname'=>$nickname];
        db('administrator')->where('id', $id)->update($update);
        return 1;
    }

    function userdel($id)
    {
        db('administrator')->where('id', $id)->delete();
        return 1;
    }

    function newuser($user, $password,$grade)
    {   $user = ['user'=>$user, 'password'=>$password, 'grade'=>$grade];
        db('administrator')->insert($user);
        return $this->success('创建成功');
    }











}














?>